package com.now.printer.ui.activity;

import android.content.Context;
import android.view.View;

import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.now.printer.R;
import com.now.printer.base.BaseActivity2;
import com.now.printer.ui.fragment.RecentlyFileFragment;

public class PrintHistoryRecordActivity extends BaseActivity2 {

    private FragmentManager fragmentManager;
    private FragmentTransaction fragmentTransaction;
    private RecentlyFileFragment recentlyFileFragment;

    @Override
    public int getLayoutId() {
        return R.layout.activity_print_history_record;
    }

    @Override
    public void doBusiness(Context mContext) {

        findViewById(R.id.id_content);

        findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


        initFragment();
    }

    private void initFragment() {
        /*在activity对应java类中通过getFragmentManager()
         *获得FragmentManager，用于管理ViewGrop中的fragment
         * */
        fragmentManager = this.getSupportFragmentManager();
        /*FragmentManager要管理fragment（添加，替换以及其他的执行动作）
         *的一系列的事务变化，需要通过fragmentTransaction来操作执行
         */
        fragmentTransaction = fragmentManager.beginTransaction();
        //实例化要管理的fragment
        recentlyFileFragment = RecentlyFileFragment.newInstance(1);
        //通过添加（事务处理的方式）将fragment加到对应的布局中
        fragmentTransaction.add(R.id.id_content, recentlyFileFragment);
        //事务处理完需要提交
        fragmentTransaction.commit();
    }
}